package cn.virens.database.common;

import java.util.List;

import org.apache.ibatis.session.RowBounds;

import cn.hutool.core.collection.CollUtil;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example;

public interface BaseMapper<T> extends Mapper<T> {
	public static final RowBounds ONE = new RowBounds(0, 1);

	public default T selectOne(Example example) {
		List<T> list = selectByExampleAndRowBounds(example, ONE);

		if (CollUtil.isNotEmpty(list)) {
			return list.get(0);
		} else {
			return null;
		}
	}
}
